package edu.ccut.saturn.component.impl;

import edu.ccut.saturn.component.IConnectionInfo;
import edu.ccut.saturn.component.loader.ComponentLoader;
import edu.ccut.saturn.component.xml.ISaturnElement;
import edu.ccut.saturn.component.xml.SaturnElement;

public class SaturnNodeConnectionInfo implements IConnectionInfo {

	private String name;

	private String source;

	private String target;

	private String style;

	public SaturnNodeConnectionInfo(String target, String source, String style,
			String name) {

		this.target = target;
		this.source = source;
		this.style = style;
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public String getStyle() {
		return style;
	}

	public void setStyle(String style) {
		this.style = style;
	}

	public ISaturnElement toSaturnElement() {
		ISaturnElement connectionElement = new SaturnElement(
				ComponentLoader.KEY_CONNECTION);

		connectionElement.addAttribute(ComponentLoader.KEY_CONNECTION_NAME,
				this.name);

		connectionElement.addAttribute(ComponentLoader.KEY_CONNECTION_TARGET,
				this.target);

		connectionElement.addAttribute(ComponentLoader.KEY_CONNECTION_SOURCE,
				this.source);

		connectionElement.addAttribute(ComponentLoader.KEY_CONNECTION_STYLE,
				this.style);

		return connectionElement;
	}

	public String toXmlStr() {
		return toSaturnElement().getXMLStr();
	}

}
